package com.ete.lib.upload.net.progress

import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import java.io.IOException

/**
 * Author:LiXian
 * <p>
 * Desc:上传进度
 * Version:1.0
 * date 2024/1/9 16:59
 */
class ProgressInterceptor(var mListener: IProgressListener) : Interceptor {

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val originalRequest: Request = chain.request()
        val progressRequest: Request = originalRequest.newBuilder()
            .method(originalRequest.method(), ProgressRequestBody(originalRequest.body(), mListener))
            .build()
        return chain.proceed(progressRequest)
    }
}